<div class="content_ads">
    <?php
        echo $this->element('top_content_ads');
    ?>
</div>
<div class="tab-content">
    <?php if($searches!=null){
    foreach ($searches as $product):
            echo '<div class="item">';
            $image=$product['Product']['picture1'];
                if(empty($image)){
                    $image = 'default_product.png';
                    $resizedFile = 'uploads/'.$image;
                }else {
                   $resizedFile = 'uploads/images_resize/'.$image;
                }
             echo $this->Html->link($this->Html->image($resizedFile), array('controller'=>'posts', 'action' => 'view', $product['Product']['id']), array('escape' => false));

            if (strlen($product['Product']['title']) > 30) {
                echo '<span class="pro-title">'.$this->Html->link(substr($product['Product']['title'], 0, 30).'...', array('controller' => 'posts', 'action' => 'view', $product['Product']['id'])).'</span>';
            }else {
                echo '<span class="pro-title">'.$this->Html->link($product['Product']['title'], array('controller' => 'posts', 'action' => 'view', $product['Product']['id'])).'</span>';
            }
            echo '<span id="pro-price">$'.$product['Product']['price'].'<i class="'.$product['Product']['status'].'"></i></span>';
            echo '<span id="modified_date">'.$product['Product']['modified_date'].'</span><br>';
            if($product['User']['first_name']) {echo '<span id="auth">'.$product['User']['first_name'].'</span>';}
            if($product['Location']['name']) {echo '<span id="address">'.$product['Location']['name'].'</span>';}
            echo '<span id="phone">'.$product['User']['phone'].'</span><br>';
            if (strlen($product['Product']['description']) > 150) {
                echo '<span id="dec">'.substr(strip_tags($product['Product']['description']), 0, 150).'...'.'</span>';
            }else {
                echo '<span id="dec">'.$product['Product']['description'].'</span>';
            }
            
            echo '<div class="total-view">';
            ?> <a href="#" class="<?php echo $product['Product']['id']; ?>"></a><a href="#" id="<?php echo $product['Product']['id']; ?>" data="<?php echo $product['Product']['id'] ?>" class="favorite"></a><?php
           
            if($product['Product']['view']) {
                echo '<span class="total-product">View :'.$product['Product']['view'].'</span>';
            }else {
                echo '<span class="total-product">View : 0</span>';
            }
            $i = 0;
            for($a=1; $a<=4; $a++){
                $picture = "picture$a";
                if($product['Product'][$picture]){
                    $i++;
                }
            }
            echo '<span class="total-image">'.$i.'</span>';

            echo '<span class="total-comment">'.count($product['Comment']).'</span>';
            $total = 0;
//            foreach ($counttoday as $today) {
//                if($product['Product']['id'] == $today['Statistic']['product_id']) {
//                    $total = $today['Statistic']['count'];
//                }
//            }
//            echo '<apan class="total-today"> Today viewed:'.$total.'</span>';
            echo '</div>';
            echo '<div class="clearfix"></div></div>';
    endforeach; } ?>
</div>